//
//  JHStatusCell.swift
//  JHSinaWeibo
//
//  Created by apple on 16/6/3.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit
import SnapKit

class JHStatusCell: UITableViewCell {
    
    var statusViewModel : JHStatusViewModel?{
        didSet{
        //给原创微博的模型赋值
            statusOriginalView.statusViewModel = statusViewModel
        }
    
    }
    
//从xib中加载会调用这个方法
    override func awakeFromNib() {
        super.awakeFromNib()
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.backgroundColor = randomColor()
        
        setupUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置界面
    private func setupUI(){
    //自定义cell添加视图不能够直接使用cell添加 需要使用cell 的contentView用添加子视图
        contentView.addSubview(statusOriginalView)
        contentView.addSubview(statusToolBar)
        //设置约束
    statusOriginalView.snp_makeConstraints { (make) in
        make.top.left.right.equalTo(self.contentView)
//设置测试高度
       // make.height.equalTo(100)
        }
        statusToolBar.snp_makeConstraints { (make) in
            make.top.equalTo(statusOriginalView.snp_bottom)
            make.right.left.equalTo(self.contentView)
            //设置高度
            make.height.equalTo(36)
        }
        //给cell的contentView的底部添加约束
        contentView.snp_makeConstraints { (make) in
            make.top.left.right.equalTo(self)
make.bottom.equalTo(statusToolBar.snp_bottom)
        }
        
    }
    //懒加载子视图
    //原创微博视图
    private lazy var statusOriginalView:JHStatusOrginView = JHStatusOrginView()
    //底部工具条
    private lazy var statusToolBar:JHStatusToobar = JHStatusToobar()
    
}
